<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1 id='box'>{{msg}}</h1>
        <hr>
        <button @click='update'>点击修改</button>
        <button @click='del'>点击销毁</button>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                msg:'生命周期函数'
            },
            methods: {
                update(){
                    this.msg = '刘为是煞笔';
                },
                del(){
                    this.$destroy();
                }
            },
            beforeCreate() {
                console.log('创建之前');
                console.log(this.msg)
            },
            created() {
                 console.log('创建之后');
                console.log(this.msg)
            },
            beforeMount() {
                console.log('挂载之前');
                console.log(document.getElementById('box'))
            },
            mounted() {
                console.log('挂载之后');
                console.log(document.getElementById('box'))
            },
            beforeUpdate() {
                console.log('更新之前');
                console.log(document.getElementById('box').innerHTML)
            },
            updated() {
                console.log('更新之后');
                console.log(document.getElementById('box').innerHTML)
            },
            beforeDestroy() {
                console.log('销毁之前')
            },
            destroyed() {
                console.log('销毁之后');
            },
        })
    </script>
</body>
</html>